#include <iostream>
#include <stdio.h>>

using namespace std;
int main()
{
    char x[255],y[255];
    int i,bsx[256]={0},bsy[256]={0},dx[256]={0},dy[256]={0},demy[256]={0},demx[256]={0};
    cout<<"\nNhap vao chuoi x: ";
        gets(x);
    cout<<"\nNhap vao chuoi y: ";
        gets(y);

    cout<<endl;
    for(i=0;x[i]!='\0';i++)
        demx[x[i]]++;
    for(i=0;i<256;i++)
        if(demx[i]) dx[i]++;

    for(i=0;y[i]!='\0';i++)
        demy[y[i]]++;
    for(i=0;i<256;i++)
        if(demy[i]) dy[i]++;

    int xd=1;
    for(int i=0;i<256;i++)
        if(dy[i]!=dx[i]){
            xd=0;
            break;
    }
    if(xd) cout<<"Chuoi tung tu";
    else if(xd==0){
        cout<<"Chuoi khong tung tu";
        for(int i=0;i<256;i++){
            if(dy[i]>dx[i])
                bsx[i]++;
            if(dx[i]>dy[i])
                bsy[i]++;
        }
        cout<<endl;

        cout<<"Chuoi x sau bo sung: "<<x<<" ";
        for(int i=0;i<256;i++)
            if(bsx[i]) cout<<char(i);
            cout<<endl;

        cout<<"Chuoi y sau bo sung: "<<y<<" ";
        for(int i=0;i<256;i++)
            if(bsy[i]) cout<<char(i);
            cout<<endl;

        cout<<"Tap ki tu tao thanh chung: ";
        for(int i=0;i<256;i++){
            if(dx[i]) cout<<char(i);
            if(bsx[i]) cout<<char(i);
        }
    }
}